package main

import "fmt"

// 结构体实例，有值类型和指针类型，值类型复制不改变外部的值，指针类型不复制，改变外部的值
type Player struct {
	Name string
}

func (p Player) attack() {
	fmt.Println(&p)
	p.Name = "tom"
	fmt.Println(p)
}
func (p *Player) attacked() {
	fmt.Println(p)
	p.Name = "kite"
	fmt.Println(p)
}

func main() {
	p1 := Player{Name: "jom"}
	fmt.Println(&p1)
	p1.attack()
	fmt.Println(p1)
	fmt.Println("------------------------")
	p2 := &Player{Name: "jerry"}
	fmt.Println(p2)
	p2.attacked()
	fmt.Println(p2)
}
